<?php 

require './configs/config.php';

// 类名 UserController

function mvc_autoload($classname)
{
    if (file_exists("./controllers/{$classname}.class.php")) {
        require "./controllers/{$classname}.class.php";
    } elseif (file_exists("./models/Model.class.php")){
        require './models/Model.class.php';
    } else {
        header("HTTP/1.0 404 not found");
        echo '<h1>404 NOT FOUND</h1>';
        exit;
    }
}

// 导入模版引擎
require './libs/Smarty.class.php';
// 注册给定的函数作为 __autoload 的实现
spl_autoload_register('mvc_autoload');


$smarty = new Smarty();
//  配置Smarty  连贯操作
$smarty->setTemplateDir('./views')
       ->setCompileDir('./runtime/views_c')
       ->setConfigDir('./configs')
       ->setCacheDir('./runtime/caches');



$c = (!empty($_GET['c']))?$_GET['c']:'Index';// 控制模块
$a = (!empty($_GET['a']))?$_GET['a']:'Index';// 模块的方法

$classname = $c.'Controller';
$controller = new $classname();
$controller->$a();








